package com.powernode.controller;

import com.powernode.domain.SysUser;
import com.powernode.model.Result;
import com.powernode.service.SysUserService;
import com.powernode.util.AuthUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 用户控制接口
 */
@Api(tags = "管理员接口管理")
@RequestMapping("sys/user")
@Slf4j
@RestController
public class SysUserController {

    @Resource
    private SysUserService sysUserService;

    @ApiOperation("根据用户ID查询用户信息")
    @GetMapping("info")
    public Result<SysUser> loadSysUserInfo(){
        // 获取用户id
        Long userId = AuthUtils.getLoginUserId();
        log.info("当前用户是: {} , 拿到该用户信息" , userId);
        // 根据用户id 查询用户i辛纳希
        SysUser sysUser = sysUserService.getById(userId);
        return Result.success(sysUser);
    }
}
